package com.zjk.wrench.design.framework.tree.node;

import com.zjk.wrench.design.framework.tree.AbstractDemoSupport;
import com.zjk.wrench.design.framework.tree.StrategyHandler;
import com.zjk.wrench.design.framework.tree.factory.DefaultStrategyFactory;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
@RequiredArgsConstructor
public class SwitchNode extends AbstractDemoSupport {
    private final AccountNode accountNode;

    @Override
    protected String doApply(String requestParameters, DefaultStrategyFactory.DynamicContext dynamicContext) throws Exception {
        log.info("【开关节点】规则决策树 requestParameters:{}", requestParameters);
        return router(requestParameters, dynamicContext);

    }

    @Override
    public StrategyHandler<String, DefaultStrategyFactory.DynamicContext, String> getStrategy(String requestParameters, DefaultStrategyFactory.DynamicContext dynamicContext) {
        return accountNode;
    }
}
